
//实现方法 @return 返回2个值，一个是带时分秒，另一个不带。
export function msToDate (msec) {
    let datetime = new Date(msec);
    let year = datetime.getFullYear();
    let month = datetime.getMonth();
    let date = datetime.getDate();
    let hour = datetime.getHours();
    let minute = datetime.getMinutes();
    let second = datetime.getSeconds();
 
    let result1 = year + 
                 '-' + 
                 ((month + 1) >= 10 ? (month + 1) : '0' + (month + 1)) + 
                 '-' + 
                 ((date + 1) < 10 ? '0' + date : date) + 
                 ' ' + 
                 ((hour + 1) < 10 ? '0' + hour : hour) +
                 ':' + 
                 ((minute + 1) < 10 ? '0' + minute : minute) + 
                 ':' + 
                 ((second + 1) < 10 ? '0' + second : second);
 
    let result2 = year + 
                 '-' + 
                 ((month + 1) >= 10 ? (month + 1) : '0' + (month + 1)) + 
                 '-' + 
                 ((date + 1) < 10 ? '0' + date : date);
 
    let result = {
        hasTime: result1,
        withoutTime: result2
    };
 
    return result;
}
//变量
// let myTime1 = 1628990100000;
// let myTime2 = 'Sun Aug 15 2021 09:15:00 GMT+0800 (中国标准时间)';
//例子
// console.log(msToDate(myTime1).hasTime);//2021-08-15 9:15:00
// console.log(msToDate(myTime1).withoutTime);//2021-08-15
// console.log(msToDate(myTime2).hasTime);//2021-08-15 9:15:00
// console.log(msToDate(myTime2).withoutTime);//2021-08-15
// 192.168.16.32 - 192.168.16.51
// 11:21:23 - 16:30:00